<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name:'费用'}"></three-title>
    <div class="layerRtb-scroll thinScroll" v-scrollHeight = "84">
        <div class="analyItem">
            <p class="analyItemTit tx-center">人</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                        <span class="cLightGray pr8">姓名</span>
                        <span>{{this.leftInfo.user_name}}</span>
                    </p>
                    <p class="col-md-4">
                        <span class="cLightGray pr8">分司</span>
                        <span>{{this.leftInfo.city}}</span>
                    </p>
                    <p class="col-md-4">
                        <span class="cLightGray pr8">电话</span>
                        <span>{{this.leftInfo.mobile}}</span>
                    </p>
            </div>
        </div>
        <div class="analyItem" >
            <p class="analyItemTit tx-center">通知财务</p>
             <div class="analyItemCon">
                 <!-- 押金缴纳口 -->
                 <div class="col-md-12" v-if="this.pmDeposit.length == 0">
                 <p class="col-md-4">
                     <span class="cLightGray pr8">
                        风险押金
                    </span>
                     <span class="cLightGray pr8">
                         <select id="joinNeedMoneys" style="width: 80px; height: 27px;">
                             <option value="30000">30000元</option>
                             </select>
                             </span>
                </p>
                <p class="col-md-4">
                     <span class="cLightGray pr8">实收</span>
                     <span class="cLightGray pr8">
                         <input value="" oninput="value=value.replace(/[^\d^\.]+/g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.')" id="fxyjMoney" style="width: 89px; height: 27px;" v-model="depositDetail">&nbsp;&nbsp;元
                           </span></p>
                           <input type="button" value="通知财务" class="uiBtn-blue uiBtn-small" style="width: 90px; height: 30px;" v-if="this.Manager.user_join_state == 1" @click="deposit()">
                </div>
                <!-- 平台费缴纳口 -->
                <div class="col-md-12" v-if="this.Manager.user_join_state == 2 && this.pmDeposit.length == 0">
                    <p class="col-md-4"><span class="cLightGray pr8">
                        平台服务费
                    </span>
                    <span class="cLightGray pr8">
                        <select id="joinNeedMoney" style="width: 80px; height: 27px;">
                            <option value="5000">5000元</option>
                            </select></span></p>
                            <p class="col-md-4">
                                <span class="cLightGray pr8">实收</span>
                                <span class="cLightGray pr8"><input value="" id="joinRealityMoney" oninput="value=value.replace(/[^\d^\.]+/g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.')" style="width: 89px; height: 27px;" v-model="joinRealityMoney">&nbsp;&nbsp;元
                   </span></p>
                   <input type="button" value="通知财务" class="uiBtn-blue uiBtn-small" style="width: 90px; height: 30px;" @click="platform()">
                </div> <!---->
                <!-- 押金未处理查看  -->
                <div class="col-md-12" v-if="this.pmDeposit.length !== 0 &&this.pmDeposit[0].pmDataSource == 1&& this.pmDeposit[0].depositState == 0">
                 <p class="col-md-4">
                     <span class="cLightGray pr8">
                        风险押金已通知财务
                    </span>
                     <span class="cLightGray pr8">
                             </span>
                </p>
                <p class="col-md-4">
                     <span class="cLightGray pr8">风险押金凭证码</span>
                     <span class="cLightGray pr8">{{this.pmDeposit[0].pmCode}}
                           </span>
                           </p>
                </div>
                <!-- 平台费未处理查看 -->
                <div class="col-md-12" v-if="this.Manager.user_join_state == 2 && this.pmDeposit.length !== 0 &&this.pmDeposit[1].pmDataSource == 17&& this.pmDeposit[1].depositState == 0">
                    <p class="col-md-4"><span class="cLightGray pr8">
                        平台服务费已通知财务
                    </span>
                    <span class="cLightGray pr8"></span></p>
                            <p class="col-md-4">
                                <span class="cLightGray pr8">平台服务费凭证码</span>
                                <span class="cLightGray pr8">{{this.pmDeposit[1].pmCode}}
                   </span></p>
                </div>
                <!-- 押金处理查看  -->
                <div class="col-md-12" v-if="this.pmDeposit.length !== 0 &&this.pmDeposit[0].pmDataSource == 1&& this.pmDeposit[0].depositState == 1">
                 <p class="col-md-4">
                     <span class="cLightGray pr8">
                        风险押金财务已确认
                    </span>
                     <span class="cLightGray pr8">
                             </span>
                </p>
                <p class="col-md-4">
                     <span class="cLightGray pr8">风险押金凭证码</span>
                     <span class="cLightGray pr8">{{this.pmDeposit[0].pmCode}}
                           </span>
                           </p>
                </div>
                <!-- 平台费处理查看 -->
                <div class="col-md-12" v-if="this.Manager.user_join_state == 2 && this.pmDeposit.length !== 0 && this.pmDeposit[1].pmDataSource == 17&& this.pmDeposit[1].depositState == 1">
                    <p class="col-md-4"><span class="cLightGray pr8">
                        平台服务费财务已确认
                    </span>
                    <span class="cLightGray pr8"></span></p>
                            <p class="col-md-4">
                                <span class="cLightGray pr8">平台服务费凭证码</span>
                                <span class="cLightGray pr8">{{this.pmDeposit[1].pmCode}}
                   </span></p>
                </div>
                   </div>

            </div>


        <div class="analyItem" v-if="this.pmDeposit.length !== 0 && this.pmDeposit[0].depositState == 1">
            <p class="analyItemTit tx-center">人</p>
            <div class="analyItemCon">
                <span></span>
                <!-- v-if="this.Manager.user_join_state == 1 && this.pmDeposit.length !== 0 && this.pmDeposit[0].pmDataSource == 1&& this.pmDeposit[0].depositState == 1" -->
                <p class="col-md-6 tx-center" v-if="this.Manager.user_join_state == 2 && this.pmDeposit.length !== 0 && this.pmDeposit[0].pmDataSource == 1&& this.pmDeposit[0].depositState == 1">
                            <el-button type="primary" @click="printCode(1)">押金打印</el-button>
                    </p>
                    <!-- v-if="this.Manager.user_join_state == 2 && this.pmDeposit.length !== 0 && this.pmDeposit[1].pmDataSource == 17&& this.pmDeposit[1].depositState == 1" -->
                <p class="col-md-6 tx-center" v-if="this.Manager.user_join_state == 2 && this.pmDeposit.length !== 0 && this.pmDeposit[1].pmDataSource == 17&& this.pmDeposit[1].depositState == 1">
                            <el-button type="primary" @click="printCode(2)">平台费打印</el-button>
                    </p>
                    <p class="col-md-6 tx-center" v-if="this.Manager.user_join_state == 1 && this.pmDeposit.length !== 0 && this.pmDeposit[0].pmDataSource == 1&& this.pmDeposit[0].depositState == 1">
                            <el-button type="primary" @click="printCode(3)">押金打印</el-button>
                    </p>
            </div>
        </div>
    </div>
            <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
             <p class="fl">
                    <span class="circlemark circlemark-lightRed"> 待</span>
             </p>
            </div>
        </div>
</div>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import {selectPmUserInfoManager, insertPmInfoAndDeposit, findStageInfoById, joinMessageMoney, getPlatformMoney} from '../../Resources/Api/index'
export default {
    data () {
        return {
            Manager: {}, // 查询
            depositDetail: 0, // 押金
            stageInfo: {},
            joinRealityMoney: 0, // 平台服务费
            pmDeposit: []
        }
    },
    created () {
        this.selectPmUserInfoManager()
        this.getPlatformMoney()
    },
    methods: {
        printCode (num) {
            if (num === 1) {
                // var pmDeposit = $('#moneys').text()
                // var pmDeposits = $("#money").val();
                // alert(pmDeposit+"money")
                // alert(pmDeposits+"money2")
                var remarks = '【入职押金】，地区：' + this.leftInfo.dq_name + '，' + this.leftInfo.user_name + '入驻平台，应收保证金10000，本次收入' + this.pmDeposit[0].pmDeposit
                // var createName = JSON.parse(sessionStorage.getItem('userinfoPerson')).UserName

                var payType = '入职押金'
                window.open('https://gxmrs.rxjy.com/printpdf/freemarker?pmUserName=' + this.leftInfo.user_name + '&createName=' + this.userInfo.as_fullName + '&pmDeposit=' + this.pmDeposit[0].pmDeposit + '&remark=' + remarks + '&payType=' + payType)
            } else if (num === 2) {
                window.open('https://pf.rxjy.com/i/voucher/PrintVoucherBySourceCode?sourcecode=' + this.pmDeposit[1].pmCode, '_blank')
            } else if (num === 3) {
                window.open('https://pf.rxjy.com/i/voucher/PrintVoucherBySourceCode?sourcecode=' + this.pmDeposit[0].pmCode, '_blank')
            }
        },
        // 获取押金明细表的内容
        getPlatformMoney () {
            this.selectPmUserInfoManager()
            getPlatformMoney({
                uid: this.leftInfo.uid
            }).then(res => {
                // alert(this.Manager.user_join_state)
                if (res.data.StatusCode === 0) {
                    this.pmDeposit = res.data.Body.moneyMaps
                    console.log(this.pmDeposit)
                }
            }).catch(err => {
                console.log('查询平台服务费 getPlatformMoney失败，原因为' + err)
            })
        },
        // 缴纳平台费
        platform () {
            this.findStageInfoById() // 获取信息
            this.deposit() // 新增押金
            joinMessageMoney({
                DivisionId: 4, // 师ID
                CorpsID: 21, // 团ID
                Subject: 477, // 科目     477【项目经理加盟】 479【设计院加盟】joinNeedMoney
                Summary: this.leftInfo.user_name + '入驻平台，应收平台费' + this.joinRealityMoney + '，本次收入' + this.joinRealityMoney, // 摘要   xx加盟商XXX应收加盟费XXX，本次收入XXX
                ShouldAmount: this.joinRealityMoney, // 应收
                Money: this.joinRealityMoney, // 本次收入
                SourceBy: this.userInfo.as_fullName, // 操作人
                SourceNoBy: this.userInfo.as_cardNo, // 操作人卡号
                CompanyName: '-', // 公司名称。没有传 "-"
                CompanyCode: '-', // 公司编号  没有传 "-"
                CompanyID: this.leftInfo.uid, // this.leftInfo.uid 项目经理的唯一标识，以后根据此字段查询项目经理已交费用
                Region: this.leftInfo.areaId, // 地区名称 没有传 "-"
                Province: '-', // 省   没有传 "-"
                Level: '-', // 城市级别   没有传 "-"
                UserName: this.leftInfo.user_name,
                DataSource: 17
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    alert('缴纳平台费成功')
                    layer.msg('通知平台费成功')
                }
            }).catch(err => {
                console.log('通知财务平台服务费 joinMessageMoney失败，原因为' + err)
            })
        },
        // 获取所有信息
        findStageInfoById () {
            findStageInfoById({
                uid: this.leftInfo.uid // this.leftInfo.uid
            }).then(result => {
                this.stageInfo = result.data.Body
            }).catch(err => {
                console.log(err)
            })
        },
        // 查询签约
        selectPmUserInfoManager () {
            selectPmUserInfoManager({
                uid: this.leftInfo.uid // this.leftInfo.uid
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    this.Manager = res.data.Body
                    // this.userJoinState = this.Manager.user_join_state
                }
            }).catch(err => {
                console.log('查询签约 selectPmUserInfoManager失败，原因为' + err)
            })
        },
        // 获取押金 缴纳押金
        deposit () {
            this.findStageInfoById()
            insertPmInfoAndDeposit({
                userType: 1,
                orderNo: '',
                pmUid: this.leftInfo.uid, // this.leftInfo.uid
                pmUserName: this.leftInfo.user_name,
                pmDataSource: 1,
                pmDeposit: this.depositDetail, // 金额
                pmCode: '', // 凭证吗
                depositState: 0, // 处理状态
                depositCreatTime: '2020-02-15', // 时间
                depositUpdateTime: '2020-02-15', // 时间 new Date()
                isDelete: 0,
                creatNo: this.userInfo.as_cardNo, // 操作人卡号
                createUser: this.userInfo.as_fullName, // 操作人姓名
                updateNo: '', // 修改人卡号
                updateUser: '', // 修改人姓名
                payee: '测试', // this.stageInfo.bank_name, // 银行卡本人
                payeeBankNo: '123654587845', // this.stageInfo.bank_account, // 银行卡号
                payeeBankName: '工商银行', // this.stageInfo.bank_open, // 银行名称 开户行
                userJoinState: this.Manager.user_join_state,
                region: this.leftInfo.areaId,
                SubjectA: 20,
                SubjectB: 553,
                divisionId: 4,
                CorpsId: 21,
                pmDepositPhoto: '',
                pmDepositRemark: '地区：' + this.leftInfo.dq_name + '，项目经理【' + this.leftInfo.user_name + '】入职押金缴纳' + this.depositDetail + '元整' // 备注

            }).then(res => {
                if (res.data.StatusCode === 0) {
                    alert('缴纳押金成功')
                    layer.msg('押金通知成功')
                }
            }).catch(err => {
                console.log('缴纳押金 insertPmInfoAndDeposit失败，原因为' + err)
            })
        },
        ...mapMutations({
            setUpdatePlate: `SET_UPDATE_PLATE`
        })
    },
    computed: {
        ...mapGetters(['leftInfo', 'userInfo'])
    }
}
</script>

